package cn.com.inossem.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import cn.com.inossem.activity.R;
import cn.com.inossem.fragment.BaGuaFragment;
import cn.com.inossem.fragment.JobsOpportunityFragment;
import cn.com.inossem.fragment.MyFriendsFragment;
import cn.com.inossem.fragment.PersonalCenterFragment;
import cn.com.inossem.viewpagerindicator.TabPageIndicator.AdapterWithTabId;


public class BottomTabTitleAdapter extends FragmentStatePagerAdapter implements
        AdapterWithTabId
{

    public static final List<Integer> TAB_TITLE_STR_ID_LIST_PHONE = new ArrayList<Integer>();
    static
    {
       
        TAB_TITLE_STR_ID_LIST_PHONE.add(R.string.global_shouye);
        TAB_TITLE_STR_ID_LIST_PHONE.add(R.string.global_bianmin);
        TAB_TITLE_STR_ID_LIST_PHONE.add(R.string.global_linliquan);
        TAB_TITLE_STR_ID_LIST_PHONE.add(R.string.global_wode);
    }

    private Context mContext;

    public BottomTabTitleAdapter(Context context, FragmentManager fm)
    {
        super(fm);

        mContext = context;
    }

    @Override
    public CharSequence getPageTitle(int position)
    {
        return mContext.getString(TAB_TITLE_STR_ID_LIST_PHONE.get(position));
    }

    @Override
    public Fragment getItem(int position)
    {
        Fragment rf = null;

        switch (TAB_TITLE_STR_ID_LIST_PHONE.get(position))
        {
            case R.string.global_shouye:
                rf = new JobsOpportunityFragment();
                break;
            case R.string.global_bianmin:
                rf = new MyFriendsFragment();
                break;
            case R.string.global_linliquan:
                rf = new BaGuaFragment();
                break;
            case R.string.global_wode:
                rf = new PersonalCenterFragment();
                break;
            default:
                break;
        }
        return rf;
    }

    @Override
    public int getCount()
    {
        return TAB_TITLE_STR_ID_LIST_PHONE.size();
    }

    @Override
    public int getTabId(int position)
    {
        return position;
    }

}
